﻿using System;
using System.ComponentModel.Composition;

namespace SetVersionNumber.VersionStrategies {

	/// <summary>
	/// Uses the current date as the first three parts of the version number,
	/// and the incrementing build # as the last part of the version number.
	/// </summary>
	[Export(typeof(IVersionStrategy))]
	public class ExplicitVersionStrategy : IVersionStrategy {

		/// <summary>
		/// The user defined version number.
		/// </summary>
		public static string UserDefinedVersionNumber { get; set; }

		/// <summary>
		/// The name of this strategy
		/// </summary>
		public const string NAME = "explicit";


		/// <summary>
		/// The name of the strategy
		/// </summary>
		public string Name {
			get { return NAME; }
		}


		/// <summary>
		/// The human-readable description of this strategy
		/// </summary>
		public string Description {
			get { return "Uses the version # specified with the --version command line option"; }
		}


		/// <summary>
		/// Get the next version number given the current version number.
		/// </summary>
		/// <param name="currentVersionNumber">The current version number</param>
		/// <returns>The new version number</returns>
		public string GetNextVersionNumber( string currentVersionNumber ) {
			if( string.IsNullOrWhiteSpace(UserDefinedVersionNumber) )
				throw new InvalidOperationException("The explicit version number was not defined");
			return UserDefinedVersionNumber;
		}

	}//class

}//namespace
